#ifndef ATCOMMOND_H
#define ATCOMMOND_H

#include <QByteArray>

class MySerialWidget;

class AtCommond
{
public:
    enum AT_CMD_TYPE{
        QUERY_LIDAR_RESOLUTION,
        QUERY_DEVICE_INFO,
        QUERY_LENS_INFO,
        STREAM_CONTROL,
        STREAM_DATA_TYPE
    };
    enum AT_CMD_STATUS{
        CMD_OK,
        CMD_FAIL
    };
    AtCommond(AT_CMD_TYPE id, MySerialWidget *serial,void *ctx);
    AT_CMD_STATUS sendAndRecv(void **out, void *ctx1);
    virtual QString cmd_str() = 0;

private:
    virtual QByteArray create_request_data(void *ctx1) = 0;
    virtual int parse_response_data(void **out, void* ctx1) = 0;
    bool check_response_valid();


private:
    AT_CMD_TYPE id;
    void *ctx;
    MySerialWidget *serial;
    QByteArray recvbuf;
    int recvlen;
};

class QueryLidarResolutionCommond: public AtCommond
{
public:
    class QueryLidarResolutionResult
    {
    public:
        int width;
        int height;
    };

    QueryLidarResolutionCommond(MySerialWidget *serial,void *ctx);
    QByteArray create_request_data(void *ctx1) override;
    int parse_response_data(void **out, void* ctx1) override;
private:
    QueryLidarResolutionResult result;
};

#endif // ATCOMMOND_H
